home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat5 / ftn / ftn_mpio.z / ftn_mpio
Encoding:
Text File  |  2002-10-03  |  7.4 KB  |  145 lines

  1. FTN_MPIO(5)                                            Last changed: 2-1-99
  2.  
  3.  
  4. NNAAMMEE
  5.      FFTTNN__MMPPIIOO - Fortran 77 multi-threaded I/O
  6.  
  7. IIMMPPLLEEMMEENNTTAATTIIOONN
  8.      IRIX systems
  9.  
  10. DDEESSCCRRIIPPTTIIOONN
  11.      Multi-threaded I/O functionality for Fortran is available with MIPSpro
  12.      Fortran 77 programs compiled with the --mmiippss33 or --mmiippss44 option.
  13.  
  14.      The 64-bit Fortran compiler and runtime libraries provide multi-
  15.      threaded I/O functionality for Fortran.  This capability is available
  16.      only to programs compiled with the --mmiippss33 or --mmiippss44 option.  To
  17.      perform Fortran I/O in parallel, the threaded subroutine must be
  18.      compiled with the --mmppiioo option.
  19.  
  20.      The following notes provide details about MPIO:
  21.  
  22.      * All subroutines in source files compiled with the --mmppiioo option use a
  23.        different I/O interface which allows MP-safe Fortran I/O.  However,
  24.        these MP interfaces do take extra runtime checks to ensure the
  25.        integrity of the I/O operations and so can affect runtime
  26.        performance (usually less than 5%).
  27.  
  28.        For applications to make the most of runtime performance, only those
  29.        subroutines which are executed in parallel or which contain
  30.        parallelized loops with I/O statements in them should be compiled
  31.        with the --mmppiioo option.  The rest should be compiled without the
  32.        --mmppiioo option.
  33.  
  34.      * The I/O runtime library ensures that only one thread gets a lock on
  35.        a particular logical unit.  The lock is only released after this
  36.        thread completes the I/O operation.
  37.  
  38.        This implies the following:
  39.  
  40.        1.  Multiple threads can write to multiple files connected to
  41.            different Fortran logical units at the same time.
  42.  
  43.        2.  You cannot have multiple threads writing to the same logical
  44.            unit and expect it to be faster. It will probably be
  45.            significantly slower due to all the lockings, queryings, and
  46.            unlockings on that same logical unit.
  47.  
  48.        3.  When you open the same file as different logical units and then
  49.            have multiple threads writing to those logical units to the same
  50.            file, the integrity of the file will be compromised.
  51.  
  52.      * The I/O runtime routines do not have control over which threads get
  53.        executed. They execute whichever thread first obtains the lock on a
  54.        particular logical unit.  Therefore, this ability to have multi-
  55.        threaded I/O is most useful in direct access or keyed access I/O
  56.        where each thread performs I/O on a pre-determined record (or where
  57.        each thread performs I/O on a different file) and, therefore, the
  58.        result is independent of the execution order of the threads.
  59.  
  60.        Because the order of the records written out or read in for
  61.        sequential files depends on which thread gets executed first, the
  62.        result could be incorrect unless the records are not sequentially
  63.        related and can be written or read in any order. In the following
  64.        example, if this loop is threaded, the numbers printed out are no
  65.        longer in the sequential order from 1 to 100 and applications
  66.        depending on the numbers being in that strict order receive the
  67.        wrong result:
  68.  
  69.                 DO 10, I=1,100
  70.                   PRINT *, I
  71.           10    CONTINUE
  72.  
  73.  
  74.  
  75.      * Because of the problem with sequential files above, the compiler
  76.        does not parallelize loops containing I/O statements automatically
  77.        because it would compromise the correctness of the application.
  78.        Loops containing I/O statements must be parallelized manually by
  79.        adding the appropriate directives.
  80.  
  81.        To use APO to analyze the loop for multi-threading, you can comment
  82.        out the I/O statements to get the ..mm file with all the
  83.        parallelization directives added to the appropriate loops, and then
  84.        uncomment the I/O statements and compile the ..mm file with the --mmppiioo
  85.        option.  Do this only if you are sure that the I/O statements won't
  86.        be affected by the order in which they are executed.
  87.  
  88.        Because of the performance loss associated with multi-threaded
  89.        Fortran I/O, the --mmppiioo option is never the default, regardless of
  90.        other compilation options.  You must explicitly specify this option
  91.        to have I/O statements inside multi-threaded loops or subroutines.
  92.  
  93.      * The Fortran standard forbids the use of a function call in a list of
  94.        items to be written out in a WWRRIITTEE or PPRRIINNTT statement if that
  95.        function itself performs I/O.  This nested I/O usage gives random
  96.        results or coredumps before the multi-threaded I/O implementation
  97.        and still gives random results if the application is not compiled
  98.        with --mmppiioo option.
  99.  
  100.        The --mmppiioo option gives the correct result if the I/O operation
  101.        inside the function is not performed on the same logical unit as the
  102.        one in the I/O statement where the function call is used.  It does
  103.        result in a deadlock and the process hangs if the nested I/O
  104.        operations are done on the same logical unit.
  105.  
  106.      * Internal file I/O is treated as if it were an independent logical
  107.        unit.  Therefore, only one thread can do internal file I/O at a
  108.        time.
  109.  
  110.      * Because the MP I/O runtime library sets its own internal lock on the
  111.        logical unit, it does not affect the normal I/O operation to the
  112.        files and does not impose additional constraint on the operability
  113.        of the I/O statements.  I/O operations to NFS-mounted files, tapes,
  114.        sockets, etc. do not have any more limitations than those they
  115.        already have, if any.
  116.  
  117.      * The --mmppiioo option affects the runtime library calls generated from
  118.        the I/O statements directly: a different set of MP-safe I/O
  119.        interfaces are used instead of the default interfaces.  Therefore,
  120.        this option, unlike those compilation options which change the
  121.        behavior of the runtime I/O library (such as --vvmmss__cccc) by setting a
  122.        flag inside the Fortran main program, is not affected whether you
  123.        have the main program written in C or written in Fortran.
  124.  
  125.      * The default maximum number of Fortran logical units that can be
  126.        opened at the same time is 100, including 4 system files.  In
  127.        single-threaded mode this limit is automatically increased if the
  128.        number opened exceeds it.  However, while I/O operations are being
  129.        executed in multi-threaded mode, if additional files are opened and
  130.        cause the number of opened files to exceed this limit, the runtime
  131.        library returns an error message asking the user to set the
  132.        environment variable FFOORRTTRRAANN__OOPPEENNEEDD__UUNNIITTSS to a bigger number and
  133.        then the program aborts.  In order to run the program to completion,
  134.        the user must set FFOORRTTRRAANN__OOPPEENNEEDD__UUNNIITTSS to a number big enough to
  135.        accommodate all the files being opened at the same time.
  136.  
  137.        To avoid setting FFOORRTTRRAANN__OOPPEENNEEDD__UUNNIITTSS, all OOPPEENN statements can be
  138.        done in single-threaded mode before doing other I/O operations in
  139.        parallel.
  140.  
  141. SSEEEE AALLSSOO
  142.      cccc(1), ff7777(1)
  143.  
  144.      This man page is available only online.
  145.